package image

import (
	"bufio"
	"io"
	"net/http"
	"os"
	"time"
)

//获取地址的图片
func GetHttpJpge(url string, name string) bool {

	client := &http.Client{
		Timeout: 5 * time.Second,
	}
	resp, err := client.Get(url)
	if err != nil {
		return false
	}

	out, err := os.Create(name)
	if err != nil {
		return false
	}
	defer out.Close()
	wt := bufio.NewWriter(out)

	body := resp.Body
	defer body.Close()

	io.Copy(wt, body)

	return true
}
